Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
it-length-prefixed
Advanced tools
Streaming length prefixed buffers with async iterables
Encode/decode streams of bytes with length-prefixes.
import { pipe } from 'it-pipe'
import * as lp from 'it-length-prefixed'
const encoded = []
// encode
await pipe(
[uint8ArrayFromString('hello world')],
(source) => lp.encode(source),
async source => {
for await (const chunk of source) {
encoded.push(chunk.slice()) // (.slice converts Uint8ArrayList to Uint8Array)
}
}
)
console.log(encoded)
// => [Buffer <0b 68 65 6c 6c 6f 20 77 6f 72 6c 64>]
const decoded = []
// decode
await pipe(
encoded, // e.g. from above
(source) => lp.decode(source),
async source => {
for await (const chunk of source) {
decoded.push(chunk.slice()) // (.slice converts Uint8ArrayList to Uint8Array)
}
}
)
console.log(decoded)
// => [Buffer <68 65 6c 6c 6f 20 77 6f 72 6c 64>]
Licensed under either of
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.
FAQs
Streaming length prefixed buffers with async iterables
We found that it-length-prefixed demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.